home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
win_q_t
/
trem.zip
/
SCROLL.C
< prev
next >
Wrap
Text File
|
1991-05-11
|
5KB
|
165 lines
/************************************************************************
*
* Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
*
*-----------------------------------------------------------------------
*
* Project: Windows Terminal Example
*
* Module: scroll.c
*
* Author: Bryan A. Woodruff (baw)
*
*
* Remarks: This module handles all scrolling of the
* terminal window
*
* Revisions:
* 01.00.000 5/ 9/91 baw Wrote it
*
************************************************************************/
#include "terminal.h"
/************************************************************************
* BOOL ScrollTerminalVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
*
* Description:
* Scrolls terminal window vertically
*
* Comments:
* 5/ 8/91 baw Wrote it
*
************************************************************************/
BOOL ScrollTerminalVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
{
int nScrollAmt ;
LOCALHANDLE hTermInfo ;
NPTERMINFO npTermInfo ;
hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
return ( FALSE ) ;
switch (wScrollCmd)
{
case SB_TOP:
nScrollAmt = -npTermInfo -> yOffset ;
break ;
case SB_BOTTOM:
nScrollAmt = npTermInfo -> yScroll - npTermInfo -> yOffset ;
break ;
case SB_PAGEUP:
nScrollAmt = -npTermInfo -> ySize ;
break ;
case SB_PAGEDOWN:
nScrollAmt = npTermInfo -> ySize ;
break ;
case SB_LINEUP:
nScrollAmt = -npTermInfo -> yChar ;
break ;
case SB_LINEDOWN:
nScrollAmt = npTermInfo -> yChar ;
break ;
case SB_THUMBPOSITION:
nScrollAmt = wScrollPos - npTermInfo -> yOffset ;
break ;
default:
LocalUnlock( hTermInfo ) ;
return ( FALSE ) ;
}
if ((npTermInfo -> yOffset + nScrollAmt) > npTermInfo -> yScroll)
nScrollAmt = npTermInfo -> yScroll - npTermInfo -> yOffset ;
if ((npTermInfo -> yOffset + nScrollAmt) < 0)
nScrollAmt = -npTermInfo -> yOffset ;
ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ;
npTermInfo -> yOffset = npTermInfo -> yOffset + nScrollAmt ;
SetScrollPos( hWnd, SB_VERT, npTermInfo -> yOffset, TRUE ) ;
LocalUnlock( hTermInfo ) ;
return ( TRUE ) ;
} /* end of ScrollTerminalVert() */
/************************************************************************
* BOOL ScrollTerminalHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
*
* Description:
* Scrolls terminal window horizontally
*
* Comments:
* 5/ 8/91 baw Wrote it
*
************************************************************************/
BOOL ScrollTerminalHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
{
int nScrollAmt ;
LOCALHANDLE hTermInfo ;
NPTERMINFO npTermInfo ;
hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
return ( FALSE ) ;
switch (wScrollCmd)
{
case SB_TOP:
nScrollAmt = -npTermInfo -> xOffset ;
break ;
case SB_BOTTOM:
nScrollAmt = npTermInfo -> xScroll - npTermInfo -> xOffset ;
break ;
case SB_PAGEUP:
nScrollAmt = -npTermInfo -> xSize ;
break ;
case SB_PAGEDOWN:
nScrollAmt = npTermInfo -> xSize ;
break ;
case SB_LINEUP:
nScrollAmt = -npTermInfo -> xChar ;
break ;
case SB_LINEDOWN:
nScrollAmt = npTermInfo -> xChar ;
break ;
case SB_THUMBPOSITION:
nScrollAmt = wScrollPos - npTermInfo -> xOffset ;
break ;
default:
LocalUnlock( hTermInfo ) ;
return ( FALSE ) ;
}
if ((npTermInfo -> xOffset + nScrollAmt) > npTermInfo -> xScroll)
nScrollAmt = npTermInfo -> xScroll - npTermInfo -> xOffset ;
if ((npTermInfo -> xOffset + nScrollAmt) < 0)
nScrollAmt = -npTermInfo -> xOffset ;
ScrollWindow( hWnd, -nScrollAmt, 0, NULL, NULL ) ;
npTermInfo -> xOffset = npTermInfo -> xOffset + nScrollAmt ;
SetScrollPos( hWnd, SB_HORZ, npTermInfo -> xOffset, TRUE ) ;
LocalUnlock( hTermInfo ) ;
return ( TRUE ) ;
} /* end of ScrollTerminalHorz() */
/************************************************************************
* End of File: scroll.c
************************************************************************/